package com.java.demo.data;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TreeImpl implements Tree {

	private final Logger LOG = LoggerFactory.getLogger(this.getClass());

	@Override
	public String findNode(int key, Node node) {
		return null;
	}

	public void log() {
		LOG.error("这是日志:{} -----{}", "====");
	}

	public static void main(String[] args) {
		TreeImpl t = new TreeImpl();
		t.log();
	}

	@Override
	public Node addNode(int key, Node root, String data) {
		Node newNode = Node.initNode(key, data);
		if (root == null) {
			root = newNode;
		} else {
			Node current = root;
			Node parentNode = null;
			while (current != null) {
				parentNode = current;
				if (key <= 0) {
					current = current.getLeftNode();
					if (current == null) {
						parentNode.setLeftNode(newNode);
						return root;
					}
				} else {
					current = current.getRightNode();
					if (current == null) {
						parentNode.setRightNode(newNode);
						return root;
					}
				}
			}
		}
		return root;
	}

	@Override
	public boolean updateNode(Node node) {
		return false;
	}

	@Override
	public boolean deleteNode(Node node) {
		return false;
	}

}
